package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizintegralgoods"
	"time"
)

type HzIntegralGoods struct {
	ent.Schema
}

func (HzIntegralGoods) Fields() []ent.Field {
	return []ent.Field{
		field.String("goods_image").NotEmpty().Comment("商品封面"),
		field.String("goods_small_image").Optional().Comment("商品图片"),
		field.Text("goods_info").NotEmpty().MaxLen(5000).Comment("商品信息(商品标题-商品描述)-多语言版本"),
		field.Int64("goods_price").Comment("商品价格"),
		field.Int64("goods_sort").Default(0).Comment("商品排序，数字越小越靠前"),
		field.Int64("goods_status").Default(bizintegralgoods.Up).Comment("上架状态 1.已上架 2.已下架"),
		field.Int64("created_at").Immutable().Default(time.Now().Unix()).Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}
func (HzIntegralGoods) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("goods_status"),
	}
}
func (HzIntegralGoods) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("积分商城商品表"),
	}
}
